#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
using namespace std;

int main()
{
    string str;
    cin >> str;
    vector<int> arr;
    unordered_set<int> hash;
    unordered_map<int, int> index;
    for (int i = 0; i < str.size(); i++)
    {
        if (hash.count(str[i] - '0'))
            arr.push_back((str[i] - '0'));
        hash.insert(str[i] - '0');
    }
    sort(arr.begin(), arr.end(), greater<int>());
    for (int i = 0; i < arr.size(); i++)
        index[arr[i]] = i;
    cout << "int[] arr = new int[]{" << arr[0];
    for (int i = 1; i < arr.size(); i++)
        cout << ',' << arr[i];
    cout << "};" << endl;
    cout << "int[] index = new int[]{" << index[str[0] - '0'];
    for (int i = 1; i < str.size(); i++)
    {
        cout << ',' << index[str[i] - '0'];
    }
    cout << "};" << endl;

    return 0;
}